package com.twelve.controller.faker;

import com.github.javafaker.Faker;
import com.twelve.annotation.BizLog;
import com.twelve.bean.faker.Recently1;
import com.twelve.bean.faker.Recently2;
import com.twelve.bean.faker.Recently3;
import com.twelve.utils.JqgridUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
 * @program: twelve
 * @description: 最近页面控制器
 * @author: geyuqi
 * @create: 2018-11-23 10:38
 **/
@Controller
@RequestMapping("/recently")
public class RencentlyController {


    private Faker faker = new Faker(Locale.CHINA);

    @Resource
    private JqgridUtil jqgridUtil;

    /**
     * 跳转页面
     * @param request
     * @return
     */
    @RequestMapping("")
    public String recently(HttpServletRequest request){
        return "faker/recently";
    }

    /**
     * 最近页面第一个列表
     * @param request
     * @return
     */
    @BizLog("最近页面第一个列表")
    @ResponseBody
    @RequestMapping("list1")
    public String list1(HttpServletRequest request){
        String pageNo = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
        String pageSize = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数

        List<Recently1> list = new ArrayList<Recently1>();
        for (int i = 0; i < 3; i++) {
            Recently1 recently1 = new Recently1();
            recently1.setAreaDeptName(faker.address().cityName());
            if (i == 0) {
                recently1.setContent("注浆泵活塞采购价格超标,原范围2750~2850, 采购价3035");
            }else if(i==1){
                recently1.setContent("缓冲托辊采购价格超标，原范围500~520,采购价600");
            }else if(i==2){
                recently1.setContent("安全帽采购价格超标,原范围15-25.采购价100");
            }
            recently1.setName(faker.name().name());
            recently1.setTime(DateFormat.getDateTimeInstance().format(new Date()));
            list.add(recently1);
        }

        return jqgridUtil.getJson(list, pageNo, 10 , 10);
    }
//    /**
//     * 最近页面第二个列表
//     * @param request
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("list2")
//    public String list2(HttpServletRequest request){
//        String pageNo = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
//        String pageSize = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数
//        List<InWarehouseRecord> list = new ArrayList<InWarehouseRecord>();
//        for (int i = 0; i < 3; i++) {
//            InWarehouseRecord inWarehouseRecord = new InWarehouseRecord();
//            inWarehouseRecord.setBuyType("进货");
//            inWarehouseRecord.setDate(DateFormat.getDateTimeInstance().format(new Date()));
//            inWarehouseRecord.setName(faker.name().name());
//            inWarehouseRecord.setNum(faker.number().randomDigit());
//            inWarehouseRecord.setPic("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1542951946235&di=f1c2c2e753dcd5ae579d9548e49f54ce&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201411%2F15%2F20141115214009_2YW82.jpeg");
//            inWarehouseRecord.setProviderCompany(faker.company().name());
//            inWarehouseRecord.setRemark("好的好的~");
//            inWarehouseRecord.setPurpose("干活用");
//            inWarehouseRecord.setSpec("0.5mm");
//            inWarehouseRecord.setUnivalent(faker.number().digit());
//            inWarehouseRecord.setTotalMoney(faker.number().digit());
//            inWarehouseRecord.setNum(faker.number().randomDigit());
//            list.add(inWarehouseRecord);
//        }
//
//        return jqgridUtil.getJson(list, pageNo, 10 , 10);
//    }
//
//    /**
//     * 最近页面第三个列表
//     * @param request
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("list3")
//    public String list3(HttpServletRequest request){
//        String pageNo = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
//        String pageSize = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数
//        List<OutWarehouseRecord> list = new ArrayList<OutWarehouseRecord>();
//        for (int i = 0; i < 3; i++) {
//            OutWarehouseRecord outWarehouseRecord = new OutWarehouseRecord();
//            outWarehouseRecord.setRecevieCompany(faker.company().name());
//            outWarehouseRecord.setDate(DateFormat.getDateTimeInstance().format(new Date()));
//            outWarehouseRecord.setName(faker.name().name());
//            outWarehouseRecord.setNum(faker.number().randomDigit());
//            outWarehouseRecord.setPic("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1542951946235&di=f1c2c2e753dcd5ae579d9548e49f54ce&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201411%2F15%2F20141115214009_2YW82.jpeg");
//            outWarehouseRecord.setProviderCompany(faker.company().name());
//            outWarehouseRecord.setRemark("好的好的~");
//            outWarehouseRecord.setPurpose("干活用");
//            outWarehouseRecord.setSpec("0.5mm");
//            outWarehouseRecord.setUnivalent(faker.number().digit());
//            outWarehouseRecord.setTotalMoney(faker.number().digit());
//            outWarehouseRecord.setNum(faker.number().randomDigit());
//            list.add(outWarehouseRecord);
//        }
//
//        return jqgridUtil.getJson(list, pageNo, 10 , 10);
//    }

    /**
     * 最近页面第二个列表
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("list2")
    public String list2(HttpServletRequest request){
        String pageNo = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
        String pageSize = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数
        List<Recently2> list = new ArrayList<Recently2>();
        for (int i = 0; i < 3; i++) {
            Recently2 recently2 = new Recently2();
            recently2.setAreaDeptName(faker.address().cityName());
            recently2.setStuffType("氧气、乙炔");
            recently2.setStuffName("氧气");

            int num = faker.number().randomDigitNotZero();
            recently2.setNum(num);
            int univalent = faker.number().randomDigitNotZero();
            recently2.setUnivalent(String.valueOf(univalent));
            recently2.setTotalMoney(String.valueOf(num * univalent));
            recently2.setPm(faker.name().name());
            recently2.setAllMan(faker.name().name());
            recently2.setLiablePerson(faker.name().name());
            recently2.setTime(DateFormat.getDateTimeInstance().format(new Date()));
            list.add(recently2);
        }

        return jqgridUtil.getJson(list, pageNo, 10 , 10);
    }

    /**
     * 最近页面第三个列表
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("list3")
    public String list3(HttpServletRequest request){
        String pageNo = request.getParameter("page"); // 取得当前页数,注意这是jqgrid自身的参数
        String pageSize = request.getParameter("rows"); // 取得每页显示行数，,注意这是jqgrid自身的参数
        List<Recently3> list = new ArrayList<Recently3>();
        for (int i = 0; i < 3; i++) {
            Recently3 recently3 = new Recently3();
            recently3.setAreaDeptName(faker.address().cityName());
            recently3.setStuffType("乙炔、氧气");
            recently3.setStuffName("乙炔");
            recently3.setReqNum(faker.number().randomDigit());
            recently3.setRealNum(faker.number().randomDigit());
            recently3.setReqMan(faker.name().name());
            recently3.setWarehouseMan(faker.name().name());
            recently3.setTime(DateFormat.getDateTimeInstance().format(new Date()));
            list.add(recently3);
        }

        return jqgridUtil.getJson(list, pageNo, 10 , 10);
    }
}
